# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libpng
pkgver=1.6.43
pkgrel=0
pkgdesc="Portable Network Graphics library"
url="http://www.libpng.org"
arch="all"
license="Libpng"
makedepends="zlib-dev gawk autoconf automake libtool"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev $pkgname-utils"
source="https://downloads.sourceforge.net/libpng/libpng-$pkgver.tar.gz
	https://downloads.sourceforge.net/sourceforge/libpng-apng/libpng-1.6.43-apng.patch.gz
	libpng-fix-arm-neon.patch
	"

# secfixes:
#   1.6.37-r0:
#     - CVE-2019-7317
#     - CVE-2018-14048
#     - CVE-2018-14550

prepare() {
	default_prepare
	# libpng-fix-arm-neon.patch modifies configure.ac
	autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -f "$pkgdir"/usr/lib/*.la
}

utils() {
	pkgdesc="$pkgdesc (pngfix utils)"

	amove usr/bin
}

sha512sums="
ac8831f28afcdf951001dff1b7a0c89cbd907a1e3ba3f21bc7bc98574b1bd7e0358ee6ac0d343b3f0a2083be730ecbd2ba8e94d0ee816f3ae58f4c664df63beb  libpng-1.6.43.tar.gz
a724f7de486920cb119818f7172fb589bc2c3c1cc1f81bb5c4da0609ab108ef9ef7406cf689a20bc4e8da69647847f550ed497b3fa99a10539e9a0abf492c053  libpng-1.6.43-apng.patch.gz
0a5efa609bda4c2a38f5110b7287020a5f9dc81583f2b05a951d897a18ce62ea80350baf52daa3d02f20dff51bbc177b3af317ab7bbc09eb23a3c252600414a5  libpng-fix-arm-neon.patch
"
